package com.company.strategy.type2;

/**
 * 具体策略角色，满减券策略，MJ是满减的缩写
 */
public class MJCouponStrategy extends CouponStrategy {

    /**
     * 优惠金额
     */
    private double discountPrice;


    public MJCouponStrategy(double discountPrice){
        this.discountPrice = discountPrice;
    }


    @Override
    public double computePrice(Order order) {
        //订单金额必须大于优惠金额
        if(order.getPrice() > discountPrice){
            return order.getPrice() - discountPrice;
        }else {
            return 0;
        }
    }
}
